package com.joyintech.vo.keysync;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.joyintech.vo.RequestHeader;

public class Test {
    public static void main(String[] args) throws JsonProcessingException {
        KeySyncRoot root = new KeySyncRoot();
        RequestHeader header = new RequestHeader();
        header.setServiceId("ID");
        root.setServiceHeader(header);

        ServiceBody body = new ServiceBody();
        Request request = new Request();
        request.setKeyLabel("X817FU01");
        body.setRequest(request);
        root.setServiceBody(body);

        XmlMapper xmlMapper = new XmlMapper();
        xmlMapper.enable(SerializationFeature.INDENT_OUTPUT); // 启用格式化输出，但不是直接控制XML声明

        String xmlString = xmlMapper.writeValueAsString(root);
        System.out.println("<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\r\n"+xmlString);

    }
}
